﻿Type.registerNamespace("BM");

BM.Iframe = {
    checkIE6: navigator && navigator.userAgent && (navigator.userAgent.indexOf('MSIE 6') != -1),

    remove: function(el) {
        if (BM.Iframe.checkIE6) {
            if (el == null) return;
            var ifr = el._hideWindowedElementsIFrame;
            if (!ifr) return;
            el._hideWindowedElementsIFrame = null;
            ifr.parentNode.removeChild(ifr);
        }
    },

    hide: function(el) {
        if (BM.Iframe.checkIE6) {
            if (el == null) return;
            var ifr = el._hideWindowedElementsIFrame;
            if (!ifr) return;
            ifr.style.display = "none";
        }
    },

    create: function(el, id) {
        if (BM.Iframe.checkIE6) {
            if (el == null) return;
            BM.Iframe.getDuplication(el);
            BM.Iframe.refreshProperties(el, id);
        }
    },

    getDuplication: function(el) {
        var ifr = el._hideWindowedElementsIFrame;
        if (ifr == null || ifr.tagName != 'IFRAME') {
            ifr = document.createElement('iframe');
            el.insertAdjacentElement('afterEnd', ifr);
            ifr.className = el.className;
            ifr.style.zIndex = el.style.zIndex + 1;
            ifr.style.filter = 'alpha(opacity=0)';
            ifr.style.position = 'absolute';
            el._hideWindowedElementsIFrame = ifr;
        }
        return ifr;
    },

    refreshProperties: function(el, id) {
        var is = el._hideWindowedElementsIFrame.style;
        is.display = "block";
        is.width = el.offsetWidth + 'px';
        is.height = el.offsetHeight + 'px';
        if (!id) {
            is.left = (el.style.posLeft) + 'px';
            is.top = (el.style.posTop) + 'px';
        } else {
            el._hideWindowedElementsIFrame.id = id;
        }
    }
}